begintownscript;

variables;
int pcs;
int choice;
int dmg_tick = 0;

body;

beginstate INIT_STATE;
break;

beginstate START_STATE;
if(get_flag(5,1) == 1) {
	if(dmg_tick == 0) {
		pcs = 0;
		while(pcs <= 119) {
			if(char_ok(pcs)) {
				damage_char(0,5,1);
				dmg_tick = 1;
			}
		pcs = pcs + 1;
	}
} else {
		dmg_tick = 0;  
	}
}
break;

beginstate EXIT_STATE;
if(get_flag(5,1) == 1) {
	message_dialog("As you leave the dragon's cave, you see that the snow has melted!","Now, the valley before you is lush and green. You should probably think about heading home, and enjoying the rest of your day off.");
change_outdoor_location(0,1,30,42);
}
break;

beginstate 10;
if(get_flag(2,2) == 1){
	if(get_flag(5,1) == 0){
		reset_dialog();
		add_dialog_str(0,"There is a huge dragon sleeping here. Do you try to blow the horn you found?",0);
		add_dialog_choice(0,"Yes.");
		add_dialog_choice(1,"No.");
		choice = run_dialog(1);

		if(choice == 2){
			message_dialog("You decide to leave the horn alone, for now.", "");
			}
			else{
				message_dialog("You blow the horn and the dragon starts to wake up. As it does, it starts getting very hot. You should probably leave now.","");
				set_flag(5,1,1);
				}
		}
} else {
	message_dialog("There is a huge dragon sleeping here. No matter what you try, you cannot get him to wake up.","");
}
break;

beginstate 11;
	if(get_flag(5,1) == 1) {
		message_dialog("The dragon seems to be waking up - you should probably leave befoe he does. You have a feeling that he'll be hungry when he does get up.","");
	} else {
		message_dialog("The dragon is fast asleep, and you can't seem to wake up. You move on.","");
	}
break;